package com.cherish.pattern.prototype.simple;

import java.util.ArrayList;

/**
 * @Classname TestPrototype
 * @Date 2019/4/7 13:14
 * @Author admin
 * @Description TODO
 */
public class TestPrototype {

    public static void main(String[] args) {
        ConcretePrototype concretePrototype = new ConcretePrototype();
        concretePrototype.setAge(12);
        concretePrototype.setName("大黄");
        concretePrototype.setHobbies(new ArrayList<>());
        System.out.println("克隆源对象：" + concretePrototype);

        Client client = new Client(concretePrototype);
        ConcretePrototype prototypeB = (ConcretePrototype)client.startClone(concretePrototype);

        System.out.println("克隆后对象：" + prototypeB);
        System.out.println("属性对比-age:" + (concretePrototype.getAge() == prototypeB.getAge()));
        System.out.println("属性对比-name:" + (concretePrototype.getName() == prototypeB.getName()));
        System.out.println("属性对比-hobbies:" + (concretePrototype.getHobbies() == prototypeB.getHobbies()));

    }

}
